package com.jyniubi.core.config.redis;

import org.springframework.data.redis.serializer.StringRedisSerializer;

import javax.annotation.Nullable;

/**
 * 为了自动给缓存key加前缀
 * todo：这个功能待实现
 */
public class PrefixStringRedisSerializer extends StringRedisSerializer {
    private String prefix;
    public PrefixStringRedisSerializer(String prefix){
        super();
        this.prefix = prefix;
    }
    @Override
    public String deserialize(byte[] bytes) {
        return super.deserialize(bytes);
    }

    @Override
    public byte[] serialize(@Nullable String key) {
        key = prefix + key;
        return super.serialize(key);
    }
}
